package com.yunupmall.mapper.FordMapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunupmall.api.po.UserCounts;
import com.yunupmall.entity.admin.memberpojo.Member;
import com.yunupmall.entity.admin.memberpojo.MemberSexCounts;
import com.yunupmall.entity.admin.memberpojo.Memberwhere;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
public interface Membermapper{


    @Select("SELECT count(*) as counts,sex FROM member group by sex")
    List<MemberSexCounts> getmanCounts();

    @Select("select * from member limit #{page},#{size}")
    List<Member> queryAllMemberdata(@Param("page") Integer page, @Param("size") Integer size);

    //获取会员表数据条数
    @Select("select count(*) as counts  from member")
    int querydatanum();

    //修改用户状态
    @Update("update member set statics = #{statics} where id= #{id}")
    int updatememberStatics(@Param("statics") Integer statics, @Param("id") Integer id);

    //条件检索
    List<Member> querywhereData(Memberwhere memberwhere);

    //数据总数查询
    int queryCounts();
    //获取用户数据统计
    @Select("SELECT DATE_FORMAT(create_time, '%m') AS month, COUNT(*) AS sum FROM member where YEAR(create_time)=#{date} GROUP BY month")
    List<UserCounts> getcounts(@Param("date") String Data);
}
